﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApi001_.Domain.Entity;

namespace WebApi001_.Domain
{
    public class DbInitializeHelper
    {
        public static void Initilizer()
        {
            using (var db=new Admin4000DbContext())
            {
                db.Database.EnsureCreated();

                var brand = new Brand
                {
                    BrandName = "Apple",
                    Description = "苹果"
                };

                db.Brands.Add(brand);

                db.SaveChanges();

                db.Products.AddRange(new Product[] 
                {
                    new Product
                    {
                        ProductName="Iphone X  银灰",
                        ShortDesc="一个描述",
                        FullDesc="详情",
                        BrandId=brand.Id
                    },new Product
                    {
                        ProductName="Iphone X  红色",
                        ShortDesc="芒果一个描述",
                        FullDesc="芒果详情",
                        BrandId=brand.Id
                    }
                });
                db.SaveChanges();
            }
        }
    }
}
